﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Sheego.Service.X400.Job.Shared;
using Sheego.Service.X400.Job.Shared.BO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sheego.Service.X400.Job.Impl
{
    class X400MessageRouter : IX400MessageRouter
    {
        private IJobRuleConfiguration JobRuleConfiguration;
        private IFileManager FileManager;
        public X400MessageRouter(IJobRuleConfiguration jobRuleConfiguration,IFileManager fileManager)
        {
            JobRuleConfiguration = jobRuleConfiguration;
            FileManager = fileManager;
        }

        #region IX400MessageRouter Members

        public void Route(IX400Message Message)
        {
            if (Message == null)
                throw new ArgumentNullException("Message");

            foreach (var rule in JobRuleConfiguration.MessageRules)
            {
                if (rule.Matcher.Match(Message))
                {
                    rule.Processor.Process(Message);
                }
            }

        }

        #endregion
    }
}
